﻿using System.Data;
using LibDBConnect;
namespace LibDataLayer
{
    public static class DalCategories
    {
        private static readonly SqlHelper Cls = new SqlHelper();
        #region[Get-Data]
        public static DataTable GetCatalogMain(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("KEYWORDS", keywords);
            return Cls.GetData("sp_Categories_Get");
        }
        public static DataTable GetCatalogMainEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cid", id);
            return Cls.GetData("sp_Categories_Get_Edit");
        }
        public static DataTable GetCatalogMainFillterStatus(int IsActive)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("IsActive", IsActive);
            return Cls.GetData("sp_Catalog_Get_FillterStatus");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(DTOCategories obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cname", obj.Cname);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            Cls.AddParameter("Scid", obj.Scid);
            return Cls.ExecuteNonQuery("sp_Categories_Insert");
        }
        public static bool Update(DTOCategories obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cid", obj.Cid);
            Cls.AddParameter("Cname", obj.Cname);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            Cls.AddParameter("Scid", obj.Scid);
            Cls.AddParameter("IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_Categories_Update");
        }
        public static bool Delete(DTOCategories obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cid", obj.Cid);
            obj.Msg = Cls.ExecuteNonQueryOutput("sp_Categories_Delete", "@Msg");
            return true;
        }
        public static bool UpdateNum(DTOCategories obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cid", obj.Cid);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            return Cls.ExecuteNonQuery("sp_Categories_Update_Num");
        }
        public static bool UpdateCheck(DTOCategories obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Cid", obj.Cid);
            Cls.AddParameter("IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_Categories_Update_Check");
        }
        #endregion

        #region[Get-Data-HomePage]
        public static DataTable GetCatalogMainHomePage(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("KEYWORDS", keywords);
            return Cls.GetData("sp_Categories_Get_HomePage");
        }
        #endregion
    }
    public class DTOCategories
    {
        public int ? Cid { get; set; }
        public string Cname { get; set; }
        public string DispPosition { get; set; }
        public int ? Scid { get; set; }
        public int Msg { get; set; }
        public bool IsActive { get; set; }
    }
}
